﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace _2D
{
    public class Sprite : IDisposable
    {
        private Texture2D texture;
        private Vector2 _position;
        public Rectangle boundingBox;

        public Vector2 position
        {
            get
            {
                return _position;
            }
            set
            {
                _position = value;
            }
        }
        

        //public Sprite(Vector2 pos)
        //{
        //    position = pos;
        //}

        public Sprite(Vector2 pos, ContentManager content, string textureName)
        {
            _position = pos;
            texture = content.Load<Texture2D>(textureName);
            boundingBox = new Rectangle((int)pos.X, (int)pos.Y, texture.Width, texture.Height);
        }

        //public void Load(ContentManager content, string textureName)
        //{
        //    texture = content.Load<Texture2D>(textureName);
        //}

        public void Draw(SpriteBatch batch)
        {
            batch.Draw(texture, _position, Color.White);

            Rectangle sourcerect = new Rectangle(0, 0,
                texture.Width, texture.Height);

            batch.Draw(texture, _position, sourcerect, Color.White,
                        0, new Vector2(0,0), 1, SpriteEffects.None, 0);
        }

        public void Update(int x, int y)
        {
            _position.X = x;
            _position.Y = y;
            boundingBox.X = x;
            boundingBox.Y = y;
        }

        #region Miembros de IDisposable

        void IDisposable.Dispose()
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
